#! /usr/bin/env python
# -*- coding:utf-8 -*-

# 用户三次登录验证
# count = 1
# while count <= 3:
#     print('这是第', count, '次登录')
#     name = input('请输入用户名')
#     password = input('请输入密码')
#     if name == 'clyang' and password == '123':
#         print('登录成功')
#         break
#     else:
#         print('登录失败')
#         if count == 3:
#             print('登录次数达到3次')
#         count += 1
# print('结束')

# 用户三次登录，当达到3次后，提示用户是否继续，如果输入Y，则继续尝试登录，如果输入N，则不再登录
# count = 1
# while count <= 3:
#     print('这是第', count, '次登录')
#     name = input('请输入用户名')
#     password = input('请输入密码')
#     if name == 'clyang' and password == '123':
#         print('登录成功')
#         break
#     else:
#         print('登录失败')
#         if count == 3:
#             print('登录次数达到3次')
#         count += 1
#     if count == 4:
#         choice = input('请输入是否继续（Y/N）')
#         if choice == 'Y':
#             count = 1
#         elif choice == 'N':
#             break
#         else:
#             print('输入错误')
#             break
# print('结束')

# 用户能登录3次，并且提示剩余登录次数
count = 2
while count >= 0:
    name = input('请输入用户名')
    password = input('请输入密码')
    if name == 'clyang' and password == '123':
        print('登录成功')
        break
    tips = '你还有%s次机会' % (count,)
    print(tips)
    count -= 1
else:
    print('登录失败，退出')
